import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'

// https://vite.dev/config/
export default defineConfig({
  plugins: [react()],
  server: {
    proxy: {
      '/api': {
        target: 'http://172.27.2.110',
        changeOrigin: true,
        secure: false,
        rewrite: (path) => path.replace(/^\/api/, ''),
      },
      '/asr': {
        target: 'https://vop.baidu.com',
        changeOrigin: true,
        secure: true,
        rewrite: (path) => path.replace(/^\/asr/, '/server_api'),
      },
      '/deepseek': {
        target: 'https://openapi.youdao.com',
        changeOrigin: true,
        secure: true,
        rewrite: (path) => path.replace(/^\/deepseek/, '/llmgateway/api/v1/chat/completions'),
      },
      '/tts': {
        target: 'https://openapi.youdao.com',
        changeOrigin: true,
        secure: true,
        rewrite: (path) => path.replace(/^\/tts/, '/ttsapi'),
      },
    },
  },
})
